var modules = {
}

const files = require.context('.', true, /\index.vue$/)
files.keys().forEach(key => {
  let moduleName = key.substring(2)
  moduleName = moduleName.substring(0, moduleName.indexOf('/'))
  modules[moduleName] = files(key).default
})

const install = function(Vue, opts = {}) {
  Object.keys(modules).forEach(key => {
    var component = modules[key]
    Vue.component(component.name, component)
  })
}

if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue)
}
export default install
